#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         __init__.py
#
# Copyright:    Copyright (c) 2004, Faulkner Technologies
#
# Author:       Brian Oliver
#
# Description:  Initialises Sub-Package Actions
#####################################################################

#####################################################################
## Knowledge Engine Library Imports
# (none - done automatically. see below)

#####################################################################
## Zope Library Imports
from Products.KnowledgeEngine.Common import getProductDirectory

#####################################################################
## Python Library Imports
import os

#####################################################################
## Python Logging Configuration
import logging
log = logging.getLogger("KnowledgeEngine.Startup")
    
#####################################################################    
## Import the KnowledgeEngine Elements
##
## Each KnowledgeEngine Action type resides in an independant package
## (named after the action) within the Actions folder
## in the KnowledgeEngine Zope Product
##
## By individually importing each Action type, they have a chance of
## performing their own initialisation, including appropriately
## registering themselves as part of the KnowledgeEngine product.

# The path to the KnowledgeEngine Action Packages
ACTIONS_PATH = getProductDirectory() + os.sep + "Actions"

# Dynamically import each of the defined Action packages in the ACTIONS_PATH
for action in [file for file in os.listdir(ACTIONS_PATH) if os.path.isdir(ACTIONS_PATH + os.sep + file)]:
    
    # Import the current action (if it doesn't contain a .)
    if action.find(".") < 0:
        log.info("Registering Action: " + action)

        exec "from Products.KnowledgeEngine.Actions." + action + " import *"

#####################################################################    
